package ACWing.TheNnderlyingAlgorithm.前缀差分;
//差分矩阵

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/11/17 22:18
 */
public class DifferenceMatrix {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int p=sc.nextInt();
        int[][]arr=new int[n+1][m+1];
        int[][]b=new int[n+2][m+2];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                arr[i][j]=sc.nextInt();
                b[i][j]=arr[i][j]-arr[i-1][j]-arr[i][j-1]+arr[i-1][j-1];
            }
        }
        while (p--!=0){
            int x1=sc.nextInt();
            int y1=sc.nextInt();
            int x2=sc.nextInt();
            int y2=sc.nextInt();
            int c=sc.nextInt();
            b[x1][y1]+=c;
            b[x2+1][y1]-=c;
            b[x1][y2+1]-=c;
            b[x2+1][y2+1]+=c;

        }
        for (int i = 1; i <=n ; i++) {
            for (int j = 1; j <= m; j++) {
                b[i][j]=b[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
                System.out.print(b[i][j]);
            }
            System.out.println();
        }

    }

}
